Backup PHYRegisters 0x429, 0x1, 0x811, 0x812, 0x814, 0x815, 0x5A, 0x59, 0x58, 0xA, 0x3, 0x80F, 0x810, 0x2B, 0x15
Perform a dummy read on PHYRegister 0x2D
- Backup the current B/G baseband attenuation value
Backup RadioRegisters 0x52, 0x43 and 0x7A
Bitwise AND PHYRegister 0x429 with 0x3FFF
Bitwise AND PHYRegister 0x1 with 0x8000
Bitwise OR PHYRegister 0x811 with 0x2
Bitwise AND PHYRegister 0x812 with 0xFFFD
Bitwise OR PHYRegister 0x811 with 0x1
Bitwise AND PHYRegister 0x812 with 0xFFFE
Bitwise OR PHYRegister 0x814 with 0x1
Bitwise AND PHYRegister 0x815 with 0xFFFE
Bitwise OR PHYRegister 0x814 with 0x2
Bitwise AND PHYRegister 0x815 with 0xFFFD
Bitwise OR PHYRegister 0x811 with 0xC
Bitwise OR PHYRegister 0x812 with 0xC
MaskSet PHYRegister 0x811 with mask 0xFFCF and set with 0x30
MaskSet PHYRegister 0x812 with mask 0xFFCF and set with 0x10
Write 0x780 to PHYRegister 0x5A
Write 0xC810 to PHYRegister 0x59
Write 0xD to PHYRegister 0x58
If the Analog Core Version is 0
Write 0x122 to PHYRegister 0x3
- Otherwise
Bitwise OR PHYRegister 0xA with 0x2000
Bitwise OR PHYRegister 0x814 with 0x4
Bitwise AND PHYRegister 0x815 with 0xFFFB
MaskSet PHYRegister 0x3 with mask 0xFF9F and set with 0x40
- If the Radio Version is 0x2050 and the Radio Revision is 2
Write 0 to RadioRegister 0x52
MaskSet RadioRegister 0x43 with mask 0xFFF0 and set 0x9
- The number of times to go through first loop will be 9
- Otherwise, if the Radio Revision is 8
Write 0xF to RadioRegister 0x43
- The number of times to go through the first loop will be 0xF
- Otherwise
- The number of times to go through the first loop will be 0
- Set the Baseband Attenuation to 0xB
- If the PHY Revision is 3 or greater
Write 0xC020 to PHYRegister 0x80F
- Otherwise
Write 0x8020 to PHYRegister 0x80F
Write 0 to PHYRegister 0x810
MaskSet PHYRegister 0x2B with mask 0xFFC0 and set with 0x1
MaskSet PHYRegister 0x2B with mask 0xC0FF and set with 0x800
Bitwise OR PHYRegister 0x811 with 0x100
Bitwise AND PHYRegister 0x812 with 0xCFFF
If the BoardFlags has BFL_EXTLNA set and the PHY Revision is 7 or newer
Bitwise OR PHYRegister 0x811 with 0x800
Bitwise OR PHYRegister 0x812 with 0x8000
Bitwise AND RadioRegister 0x7A with 0xF7
- Loop, starting at 0 to the value found above
Write the value found above for the number of times through the loop to RadioRegister 0x43 (constant through the loop)
MaskSet PHYRegister 0x812 with mask 0xF0FF and set with the loop position left shifted by 8
MaskSet PHYRegister 0x15 with mask 0xFFF and set with 0xA000
MaskSet PHYRegister 0x15 with mask 0xFFF and set with 0xF000
- Delay for 20 uSec
If the value of PHYRegister 0x2D is 0xDFC or greater (unsigned)
- Break from the loop
- Save the number of times we went through the loop
- Save the remaining number of times we could have looped
- If the number of times we went through the first loop was 8 or higher
Bitwise OR PHYRegister 0x812 with 0x30
- Loop from the number of times we went through the first loop loop - 8 to 0xF
MaskSet PHYRegister 0x812 with mask 0xF0FF and set with the loop position left shifted by 8
MaskSet PHYRegister 0x15 with mask 0x0FFF and set with 0xA000
MaskSet PHYRegister 0x15 with mask 0x0FFF and set with 0xF000
- Delay for 20 uSec
If the value of PHYRegister 0x2D is 0xDFC or greater (unsigned)
- Break
- Save 24 - 3 * the number of times through this loop (this is the result of the second loop)
Restore PHYRegisters 0x814, 0x815, 0x5A, 0x59, 0x58, 0xA, 0x3, 0x80F, 0x810, 0x2B and 0x15
- Restore the original Baseband Attenuation value
Restore RadioRegisters 0x52, 0x43 and 0x7A
Write the backed up value of PHYRegister 0x811 OR'd with 0x3 to PHYRegister 0x811
- Delay for 10 uSec
Restore PHYRegisters 0x811, 0x812, 0x429 and 0x1
- The first saved Loopback Gain value is number of times we went through the first loop * 6 - the number of times remaining in the first loop * 4, then subtract 0xB from the result (this is the Maximum Loopback Gain in hdB)
- The second saved Loopback Gain value is the result of the second loop * 2 (this is the TRSW RX Gain in hdB)